#!/bin/bash
exec >trafficgen-server-stop-stderrout.txt 
exec 2>&1

. /usr/bin/trafficgen-base || (echo "/usr/bin/trafficgen-base not found"; exit 1)

if [ -e trafficgen-server.pid ]; then
    pid=`cat trafficgen-server.pid`
    echo "Going to kill pid $pid"
    kill -15 $pid
    sleep 3
    if [ -e /proc/$pid ]; then
        echo "PID $pid still exists, trying kill -9"
        kill -9 $pid
    fi
else
    echo "trafficgen-server.pid not found"
    echo "PWD: `/bin/pwd`"
    echo "LS: `/bin/ls`"
    exit 1
fi
